cmake_minimum_required(VERSION 3.5)

project(XCScreensaver)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set (QT_COMPONENTS Core Gui Widgets Network X11Extras Test)
find_package(Qt5 REQUIRED ${QT_COMPONENTS})

find_package(X11 REQUIRED)
#find_package(xext REQUIRED)

set(pam_include_path /usr/include/security)
set(pam_lib_path /usr/lib)

include_directories(pam_include_path)
link_directories(pam_lib_path)

set (SOURCES
    src/baseui/battery.cpp
    src/baseui/arrowwidget.cpp
    src/baseui/keyinputwidget.cpp
    src/baseui/systemrebootdialog.cpp
    src/common/acctauthenticate.cpp
    src/common/localsetting.cpp
    src/common/loginlogical.cpp
    src/common/batteryinfo.cpp
    src/common/xwindowmanager.cpp
    src/main.cpp
    src/mainwindow.cpp)

set (HEADERS
    src/baseui/battery.h
    src/baseui/arrowwidget.h
    src/baseui/keyinputwidget.h
    src/baseui/systemrebootdialog.h
    src/common/acctauthenticate.h
    src/common/localsetting.h
    src/common/loginlogical.h
    src/common/batteryinfo.h
    src/common/xwindowmanager.h
    src/utils/log.h
    src/utils/version.h
    src/mainwindow.h)

set (FORMS
    src/baseui/keyinputwidget.ui
    src/baseui/systemrebootdialog.ui
    src/mainwindow.ui)

set (RESOURCES
    resource/xcscreensaver.qrc
    resource/xcscreensaver.qss)

add_executable(xc-screensaver ${SOURCES} ${HEADERS} ${FORMS} ${RESOURCES})


target_link_libraries(xc-screensaver
        Qt5::Core
        Qt5::Gui
        Qt5::Widgets
        Qt5::Network
        Qt5::X11Extras
        X11
        pam
    )

#########################    XCScreensaverTest    ###########################

#set (TEST_SOURCES
#    src/testcase/testmain.cpp
#    src/testcase/testbatteryinfo.cpp
#    src/testcase/testnetworkinfo.cpp
#    src/common/batteryinfo.cpp
#    src/common/networkinfo.cpp)


#set (TEST_HEADERS
#    src/common/batteryinfo.h
#    src/common/networkinfo.h
#    src/testcase/testbatteryinfo.h
#    src/testcase/testnetworkinfo.h )

#add_executable(DualSystemTest ${TEST_SOURCES} ${TEST_HEADERS})

#target_link_libraries(xc-screensaver-test
#        Qt5::Core
#        Qt5::Gui
#        Qt5::Widgets
#        Qt5::Network
#        Qt5::X11Extras
#        Qt5::Test
#        X11
#    )
